﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using NthDownload.Common.Mapping;

namespace NthDownload.DownloadPlugins.Http
{
    public class HttpCredentialsCollection : ObservableCollection<HttpCredentials>, ICloneable
    {
        #region Constructors

        public HttpCredentialsCollection() 
            : base()
        {
        }

        public HttpCredentialsCollection(IEnumerable<HttpCredentials> collection)
            : base(collection)
        {
        }

        public HttpCredentialsCollection(IList<HttpCredentials> list)
            : base(list)
        {
        }

        #endregion Constructors

        #region IClonable

        public object Clone()
        {
            //
            // Clone items in the current collection
            //
            List<HttpCredentials> clonedItems = new List<HttpCredentials>();

            foreach (HttpCredentials item in this)
            {
                clonedItems.Add((HttpCredentials)ObjectMappingService.Clone(item));
            }

            return new HttpCredentialsCollection(clonedItems);
        }

        #endregion IClonable
    }
}
